package com.st.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class AppListener implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent sce)  { 
    	System.out.println("App销毁");
    }

    public void contextInitialized(ServletContextEvent sce)  { 
    	System.out.println("App初始化");
    	// 初始化当前在线人数
    	ServletContext app = sce.getServletContext();
    	app.setAttribute("onlineCount", 1);
    	app.setAttribute("loginCount", 0);
    }
	
}
